package com.iims.common.core.domain.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.iims.common.core.domain.HttpParamMap;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 部门表 cmis_sys_dept
 *
 * @author fanpei
 */
@ApiModel("部门实体")
@Data
@NoArgsConstructor
@Accessors(chain = true)
@TableName("cmis_sys_department")
public class SysDept extends HttpParamMap implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 部门ID
     */
    @ApiModelProperty(name = "部门ID", value = "主键,修改时必传", position = -1)
    @TableId(value = "dept_id", type = IdType.AUTO)
    private Long deptId;

    /**
     * 父部门ID
     */
    @ApiModelProperty(value = "父部门ID,一级节点为0", required = true)
    private Long parentId;

    /**
     * 祖级列表
     */
    @ApiModelProperty(hidden = true)
    private String ancestors;

    /**
     * 部门名称
     */
    @ApiModelProperty(value = "部门名称,部门名称长度不能超过30个字符", required = true)
    @NotBlank(message = "部门名称不能为空")
    @Size(min = 0, max = 30, message = "部门名称长度不能超过30个字符")
    private String deptName;

    /**
     * 显示顺序
     */
    @ApiModelProperty(value = "显示排序", required = true)
    private Integer orderNum;

    /**
     * 负责人
     */
    @ApiModelProperty(value = "负责人", required = true)
    private String leader;

    /**
     * 联系电话
     */
    @ApiModelProperty(value = "联系电话:联系电话长度不能超过11个字符")
    @Size(min = 0, max = 11, message = "联系电话长度不能超过11个字符")
    private String phone;

    /**
     * 邮箱
     */
    @ApiModelProperty(value = "邮箱:邮箱长度不能超过50个字符")
    @Email(message = "邮箱格式不正确")
    @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
    private String email;

    /**
     * 部门状态:0正常,1停用
     */
    @ApiModelProperty(value = "状态:来源于字典sys_normal_disable", required = true)
    private String status;

    /**
     * 创建者
     */
    @ApiModelProperty(hidden = true)
    @TableField(fill = FieldFill.INSERT)
    private String createBy;

    /**
     * protected 创建时间
     */
    @ApiModelProperty(hidden = true)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(fill = FieldFill.INSERT)
    private Date createTime;

    /**
     * 更新者
     */
    @ApiModelProperty(hidden = true)
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private String updateBy;

    /**
     * 更新时间
     */
    @ApiModelProperty(hidden = true)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;

    /**
     * 删除标志（0代表存在 2代表删除）
     */
    @ApiModelProperty(hidden = true)
    @TableLogic(value = "0", delval = "2")
    protected String delFlag;


    /**
     * 父部门名称
     */
    @ApiModelProperty(hidden = true)
    @TableField(exist = false)
    private String parentName;

    /**
     * 子部门
     */
    @ApiModelProperty(hidden = true)
    @TableField(exist = false)
    private List<SysDept> children = new ArrayList<SysDept>();

}
